package com.exam.api.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.api.dao.ExamDao;
import com.exam.api.dto.ExamDTO;
import com.exam.api.service.ExamService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @description: 考试信息业务层实现类
* @author: wuming
* @create: 2024.05.03 13:24:03
*/
@Service("examService")
public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamDTO> implements ExamService {

    @Override
    public Page<ExamDTO> basePage(ExamDTO examDTO) {
        if (null != examDTO.getCurrent() && null != examDTO.getPageSize())
            examDTO.setCurrent((examDTO.getCurrent() - 1) * examDTO.getPageSize());
        List<ExamDTO> list = this.baseMapper.findList(examDTO);
        int count = this.baseMapper.findPageCount(examDTO);
        Page<ExamDTO> page = new Page<>();
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<ExamDTO> findList(ExamDTO examDTO) {
        return this.baseMapper.findList(examDTO);
    }

}
